/**
 * 全局变量
 */
var dIds = new Array();//删除了的合同产品信息ID数组
var i = 0;//数组下标

//删除
$(".deleteRowBy").live("click",function(){
	var obj = $(this);
	var submit = function (v, h, f) {
		if (v == 'ok'){ 
			dIds[i] = $(obj).parent().parent().children("td:eq(0)").children("input:eq(0)").val();
			i++;
			$(obj).parent().parent().remove();
		}else if (v == 'cancel'){
			return true;
		}
	};
	$.jBox.confirm("确认删除此信息吗？", "提示", submit); 
}); 

/**
 * 保存合同信息
 */
function saveDetail(){
	var json = "";
	if($("#code").val() == null || $("#code").val() == ''){
		$.jBox.tip("请输入内部合同订单号！");
		return;
	}
		$.each($("#productInfoTbody tr"), function(i,info){
			var virtualDetailId = $("#productInfoTbody tr:eq("+i+") input[name=virtualDetailId]").val();//合同产品信息ID
			var productName = $("#productInfoTbody tr:eq("+i+") input[name=productName]").val();//产品名称
			var productCode = $("#productInfoTbody tr:eq("+i+") input[name=productCode]").val();//产品代码
			var specifications = $("#productInfoTbody tr:eq("+i+") input[name=specifications]").val();//规格
			var brand = $("#productInfoTbody tr:eq("+i+") input[name=brand]").val();//品牌
			var packaging = $("#productInfoTbody tr:eq("+i+") input[name=packaging]").val();//封装
			var unit = $("#productInfoTbody tr:eq("+i+") input[name=unit]").val();//单位
			var supplier = $("#productInfoTbody tr:eq("+i+") input[name=supplier]").val();//供应商
			var noTaxPrice = $("#productInfoTbody tr:eq("+i+") input[name=noTaxPrice]").val();//未税价格
			var taxPrice = $("#productInfoTbody tr:eq("+i+") input[name=taxPrice]").val();//含税价格
			var count = $("#productInfoTbody tr:eq("+i+") input[name=count]").val();//数量
			var brandReplace = $("#productInfoTbody tr:eq("+i+") input[name=brandReplace]").val();//品牌替代说明
			var abnormalProblem = $("#productInfoTbody tr:eq("+i+") input[name=abnormalProblem]").val();//异常问题确认
			var executor = $("#productInfoTbody tr:eq("+i+") input[name=executor]").val();//对应负责人
			var enquiryDate = $("#productInfoTbody tr:eq("+i+") input[name=enquiryDate]").val();//询价日期
			var abnormalProblem = $("#productInfoTbody tr:eq("+i+") input[name=abnormalProblem]").val();//异常问题确认
			var deliveryDate = $("#productInfoTbody tr:eq("+i+") input[name=deliveryDate]").val();//送货日期
			var expirationDate = $("#productInfoTbody tr:eq("+i+") input[name=expirationDate]").val();//保质期
			var affirmFlag = $("#productInfoTbody tr:eq("+i+") input[name=affirmFlag]").val();//是否中标
			var virtualDetailRemarks = $("#productInfoTbody tr:eq("+i+") input[name=virtualDetailRemarks]").val();//备注
			
			var productCodeNum = $("#productInfoTbody tr:eq("+i+") input[name=productCodeNum]").val();// 产品编号
			var supplierCodeNum = $("#productInfoTbody tr:eq("+i+") input[name=supplierCodeNum]").val();// 供应商编号
			if(typeof(virtualDetailId) == "undefined"){
				virtualDetailId = "";
			}
			if(typeof(productName) == "undefined"){
				productName = "";
			}

			if(typeof(productCode) == "undefined"){
				productCode = "";
			}

			if(typeof(specifications) == "undefined"){
				specifications = "";
			}

			if(typeof(brand) == "undefined"){
				brand = "";
			}

			if(typeof(packaging) == "undefined"){
				packaging = "";
			}

			if(typeof(unit) == "undefined"){
				unit = "";
			}

			if(typeof(supplier) == "undefined"){
				supplier = "";
			}
			if(typeof(noTaxPrice) == "undefined"){
				noTaxPrice = "";
			}
			if(typeof(taxPrice) == "undefined"){
				taxPrice = "";
			}
			
			if(typeof(count) == "undefined"){
				count = "";
			}
			if(typeof(brandReplace) == "undefined"){
				brandReplace = "";
			}
			if(typeof(abnormalProblem) == "undefined"){
				abnormalProblem = "";
			}
			if(typeof(executor) == "undefined"){
				executor = "";
			}
			if(typeof(abnormalProblem) == "undefined"){
				abnormalProblem = "";
			}
			if(typeof(deliveryDate) == "undefined"){
				deliveryDate = "";
			}
			if(typeof(expirationDate) == "undefined"){
				expirationDate = "";
			}
			if(typeof(virtualDetailRemarks) == "undefined"){
				virtualDetailRemarks = "";
			}
			if(typeof(enquiryDate) == "undefined"){
				enquiryDate = "";
			}
			if(typeof(affirmFlag) == "undefined"){
				affirmFlag = "";
			}
			if(productCodeNum == "undefined"){
				productCodeNum = "";
			}
			if(supplierCodeNum == "undefined"){
				supplierCodeNum = "";
			}
			if(i != 0){
				json = json+','
			}
			json = json+'{"virtualDetailId":"'+virtualDetailId+'","productName":"'+productName+'","productCode":"'+productCode+
				'","specifications":"'+specifications+'","brand":"'+brand+'","packaging":"'+packaging+'","unit":"'+unit+
				'","supplier":"'+supplier+'","count":"'+count+'","noTaxPrice":"'+noTaxPrice+'","taxPrice":"'+taxPrice+
				'","brandReplace":"'+brandReplace+'","abnormalProblem":"'+abnormalProblem+'","executor":"'+executor+
			    '","enquiryDate":"'+enquiryDate+'","deliveryDate":"'+deliveryDate+'","expirationDate":"'+expirationDate+
			    '","affirmFlag":"'+affirmFlag+'","remarks":"'+virtualDetailRemarks+
			    '","productCodeNum":"'+productCodeNum+'","supplierCodeNum":"'+supplierCodeNum+'"}';
		});
		var virtualDetail = '['+json+']';
		$("input[name=virtualDetail]").val(virtualDetail);
		$("input[name=ids]").val(dIds);
		$("#saveForm").submit();//提交表单
}


/**
 * 修改合同产品信息
 * @param obj
 */
function editVirtualDetail(obj){
	$("#productNameEdit").attr('value',$(obj).parent().parent().children("td").children("span[class=productInfoNameSpan]").html());
	$("#productCodeEdit").attr('value',$(obj).parent().parent().children("td").children("span[class=productCodeSpan]").html());
	$("#specificationsEdit").attr('value',$(obj).parent().parent().children("td").children("span[class=specificationsSpan]").html());
	$("#brandEdit").attr('value',$(obj).parent().parent().children("td").children("span[class=brandSpan]").html());
	$("#packagingEdit").attr('value',$(obj).parent().parent().children("td").children("span[class=packagingSpan]").html());
	$("#unitEdit").attr('value',$(obj).parent().parent().children("td").children("span[class=unitNameSpan]").html());
	$("#supplierEdit").attr('value',$(obj).parent().parent().children("td").children("span[class=supplierNameSpan]").html());
	$("#executorEdit").attr('value',$(obj).parent().parent().children("td").children("span[class=executorSpan]").html());
	$("#noTaxPriceEdit").attr('value',$(obj).parent().parent().children("td").children("span[class=noTaxPriceSpan]").html());
	$("#taxPriceEdit").attr('value',$(obj).parent().parent().children("td").children("span[class=taxPriceSpan]").html());
	$("#countEdit").attr('value',$(obj).parent().parent().children("td").children("span[class=countSpan]").html());
	$("#brandReplaceEdit").attr('value',$(obj).parent().parent().children("td").children("span[class=brandReplaceSpan]").html());
	$("#abnormalProblemEdit").attr('value',$(obj).parent().parent().children("td").children("span[class=abnormalProblemSpan]").html());
	$("#enquiryDateEdit").attr('value',$(obj).parent().parent().children("td").children("span[class=enquiryDateSpan]").html());
	$("#deliveryDateEdit").attr('value',$(obj).parent().parent().children("td").children("span[class=deliveryDateSpan]").html());
	$("#expirationDateEdit").attr('value',$(obj).parent().parent().children("td").children("span[class=expirationDateSpan]").html());
	
	$("#productCodeNumEdit").attr('value',$(obj).parent().parent().children("td").children("span[class=productCodeNumSpan]").html());
	$("#supplierCodeNumEdit").attr('value',$(obj).parent().parent().children("td").children("span[class=supplierCodeNumSpan]").html());
	var affirmFlagValue=$(obj).parent().parent().children("td").children("span[class=affirmFlagSpan]").children("input").val();
	if(affirmFlagValue==1){
		$("input[name=affirmFlag][value=1]").attr("checked","checked");
		$("input[name=affirmFlag][value=0]").removeAttr("checked");
	}
	else{
		$("input[name=affirmFlag][value=0]").attr("checked","checked");
		$("input[name=affirmFlag][value=1]").removeAttr("checked");
	}
	$("#remarksEdit").html($(obj).parent().parent().children("td").children("span[class=remarksSpan]").html());
}
 

//修改
function editRow(obj){
editVirtualDetail(obj);
var html =$("#editPro").html();
var states = {};
states.state  = {
	content : html,
	buttons : {
		'选择' : true,
		'关闭' : false
	},
	submit : function(v, h, f) {
		if (v == false) {
			return true;
		} else {
		    $(obj).parent().parent().children("td").children("span[class=productInfoNameSpan]").html(h.find("#productNameEdit").val());
			$(obj).parent().parent().children("td").children("span[class=productCodeSpan]").html(h.find("#productCodeEdit").val());
			$(obj).parent().parent().children("td").children("span[class=specificationsSpan]").html(h.find("#specificationsEdit").val());
			$(obj).parent().parent().children("td").children("span[class=brandSpan]").html(h.find("#brandEdit").val());
			$(obj).parent().parent().children("td").children("span[class=packagingSpan]").html(h.find("#packagingEdit").val());
			$(obj).parent().parent().children("td").children("span[class=unitNameSpan]").html(h.find("#unitEdit").val());
			$(obj).parent().parent().children("td").children("span[class=supplierNameSpan]").html(h.find("#supplierEdit").val());
			$(obj).parent().parent().children("td").children("span[class=noTaxPriceSpan]").html(h.find("#noTaxPriceEdit").val());
			$(obj).parent().parent().children("td").children("span[class=taxPriceSpan]").html(h.find("#taxPriceEdit").val());
			$(obj).parent().parent().children("td").children("span[class=countSpan]").html(h.find("#countEdit").val());
			$(obj).parent().parent().children("td").children("span[class=brandReplaceSpan]").html(h.find("#brandReplaceEdit").val());
			$(obj).parent().parent().children("td").children("span[class=abnormalProblemSpan]").html(h.find("#abnormalProblemEdit").val());
			$(obj).parent().parent().children("td").children("span[class=enquiryDateSpan]").html(h.find("#enquiryDateEdit").val());
			$(obj).parent().parent().children("td").children("span[class=deliveryDateSpan]").html(h.find("#deliveryDateEdit").val());
			$(obj).parent().parent().children("td").children("span[class=expirationDateSpan]").html(h.find("#expirationDateEdit").val());
			$(obj).parent().parent().children("td").children("span[class=remarks]").html(h.find("#remarksEdit").val());
			$(obj).parent().parent().children("td").children("span[class=executorSpan]").html(h.find("#executorEdit").val()); 
			
			$(obj).parent().parent().children("td").children("span[class=productCodeNumSpan]").html(h.find("#productCodeNumEdit").val());
			$(obj).parent().parent().children("td").children("span[class=supplierCodeNumSpan]").html(h.find("#supplierCodeNumEdit").val());
			//affirmFlagSpanError
			var affirmFalgValue ;
			var flag = $("input[name=affirmFlag]");
			for(var i=0; i<flag.length; i ++){
			   if(flag[i].checked){
			      affirmFalgValue = flag[i].value;
			   }
			}
			if(affirmFalgValue == 1){
			  $(obj).parent().parent().children("td").children("span[class=affirmFlagSpan]").html("<i class=\"icon-ok\" style=\"color: red;\"></i><input type=\"hidden\" name=\"affirmFlag\" value=\""+affirmFalgValue+"\" />");
			}else{
			  $(obj).parent().parent().children("td").children("span[class=affirmFlagSpan]").html("<i class=\"icon-remove\"></i><input type=\"hidden\" name=\"affirmFlag\" value=\""+affirmFalgValue+"\" />");
			}
			
			$(obj).parent().parent().children("td").children("input[name=productName]").val(h.find("#productNameEdit").val());
			$(obj).parent().parent().children("td").children("input[name=productCode]").val(h.find("#productCodeEdit").val());
			$(obj).parent().parent().children("td").children("input[name=specifications]").val(h.find("#specificationsEdit").val());
			$(obj).parent().parent().children("td").children("input[name=brand]").val(h.find("#brandEdit").val());
			$(obj).parent().parent().children("td").children("input[name=packaging]").val(h.find("#packagingEdit").val());
			$(obj).parent().parent().children("td").children("input[name=unit]").val(h.find("#unitEdit").val());
			$(obj).parent().parent().children("td").children("input[name=supplier]").val(h.find("#supplierEdit").val());
			$(obj).parent().parent().children("td").children("input[name=noTaxPrice]").val(h.find("#noTaxPriceEdit").val());
			$(obj).parent().parent().children("td").children("input[name=taxPrice]").val(h.find("#taxPriceEdit").val());
			$(obj).parent().parent().children("td").children("input[name=count]").val(h.find("#countEdit").val());
			$(obj).parent().parent().children("td").children("input[name=brandReplace]").val(h.find("#brandReplaceEdit").val());
			$(obj).parent().parent().children("td").children("input[name=abnormalProblem]").val(h.find("#abnormalProblemEdit").val());
			$(obj).parent().parent().children("td").children("input[name=enquiryDate]").val(h.find("#enquiryDateEdit").val());
			$(obj).parent().parent().children("td").children("input[name=deliveryDate]").val(h.find("#deliveryDateEdit").val());
			$(obj).parent().parent().children("td").children("input[name=expirationDate]").val(h.find("#expirationDateEdit").val());
			$(obj).parent().parent().children("td").children("input[name=virtualDetailRemarks]").val(h.find("#remarksEdit").val());
			$(obj).parent().parent().children("td").children("input[name=executor]").val(h.find("#executorEdit").val());
			$(obj).parent().parent().children("td").children("input[name=affirmFlag]").val(h.find("#affirmFlagEdit").val());
			
			
			$(obj).parent().parent().children("td").children("input[name=productCodeNum]").val(h.find("#productCodeNumEdit").val());
			$(obj).parent().parent().children("td").children("input[name=supplierCodeNum]").val(h.find("#supplierCodeNumEdit").val());
			return true;
		}
		return false;
	}
};
$.jBox.open(states, '内部合同修改', 500,500);
}
/**
 * 添加产品
 */
 function addPro(){
		$.jBox($("#divPro").html(), {
			id: 'JBoxDivPro', 
			title : "添加产品",
			width : 555,
			height : 555,
			buttons : {"选择" : false , "关闭" : true },
			submit : function(v, h, f) {
				if (v == false) {
					if(h.find("#productName").val() != "undefined"  && h.find("#productName").val() != ''){
					var newRow = '<tr>';
					if(typeof($("#productInfoNameSpan").html())!="undefined"){
						newRow += '<td style="white-space: normal;"><input type="hidden" name="virtualDetailId" value="'+h.find("#virtualDetailId").val()+'">'+
							'<span class="productInfoNameSpan">'+h.find("#productName").val()+'</span>'+
							'<input type="hidden" name="productName" value="'+h.find("#productName").val()+'"/>'+
							'<input type="hidden" name="productCodeNum" value="'+h.find("#productCodeNum").val()+'"/></td>';
					}
					if(typeof($("#productCodeSpan").html())!="undefined"){
						newRow += '<td style="white-space: normal;"><span class="productCodeSpan">'+h.find("#productCode").val()+'</span>'+
						'<input type="hidden" name="productCode" value="'+h.find("#productCode").val()+'"/></td>';
					}
					if(typeof($("#specificationsSpan").html())!="undefined"){
						newRow += '<td style="white-space: normal;"><span class="specificationsSpan">'+h.find("#specifications").val()+'</span>'+
						'<input type="hidden" name="specifications" value="'+h.find("#specifications").val()+'"/></td>';
					}
					if(typeof($("#brandSpan").html())!="undefined"){
						newRow += '<td style="white-space: normal;"><span class="brandSpan">'+h.find("#brand").val()+'</span>'+
						'<input type="hidden" name="brand" value="'+h.find("#brand").val()+'"/></td>';
					}
					if(typeof($("#packagingSpan").html())!="undefined"){
						newRow += '<td style="white-space: normal;"><span class="packagingSpan">'+h.find("#packaging").val()+'</span>'+
						'<input type="hidden" name="packaging" value="'+h.find("#packaging").val()+'"/></td>';
					}
					if(typeof($("#unitSpan").html())!="undefined"){
						newRow += '<td style="white-space: normal;"><span class="unitNameSpan">'+h.find("#unit").val()+'</span>'+
						'<input type="hidden" name="unit" value="'+h.find("#unit").val()+'"/></td>';
					}
					if(typeof($("#supplierSpan").html())!="undefined"){
						newRow += '<td style="white-space: normal;"><span class="supplierNameSpan">'+h.find("#supplier").val()+'</span>'+
						'<input type="hidden" name="supplier" value="'+h.find("#supplier").val()+'"/>'+
						'<input type="hidden" name="supplierCodeNum" value="'+h.find("#supplierCodeNum").val()+'"/></td>';
					}
					if(typeof($("#noTaxPriceSpan").html())!="undefined"){
						newRow += '<td style="white-space: normal;"><span class="noTaxPriceSpan">'+h.find("#noTaxPrice").val()+'</span>'+
						'<input type="hidden" name="noTaxPrice" value="'+h.find("#noTaxPrice").val()+'"/></td>';
					}
					if(typeof($("#taxPriceSpan").html())!="undefined"){
						newRow += '<td style="white-space: normal;"><span class="taxPriceSpan">'+h.find("#taxPrice").val()+'</span>'+
						'<input type="hidden" name="taxPrice" value="'+h.find("#taxPrice").val()+'"/></td>';
					}
					
					if(typeof($("#countSpan").html())!="undefined"){
						newRow += '<td style="white-space: normal;"><span class="countSpan">'+h.find("#count").val()+'</span>'+
						'<input type="hidden" name="count" value="'+h.find("#count").val()+'"/></td>';
					}
					if(typeof($("#brandReplaceSpan").html())!="undefined"){
						newRow += '<td style="white-space: normal;"><span class="brandReplaceSpan">'+h.find("#brandReplace").val()+'</span>'+
						'<input type="hidden" name="brandReplace" value="'+h.find("#brandReplace").val()+'"/></td>';
					}
					if(typeof($("#abnormalProblemSpan").html())!="undefined"){
						newRow += '<td style="white-space: normal;"><span class="abnormalProblemSpan">'+h.find("#abnormalProblem").val()+'</span>'+
						'<input type="hidden" name="abnormalProblem" value="'+h.find("#abnormalProblem").val()+'"/></td>';
					}
					if(typeof($("#executorSpan").html())!="undefined"){
						newRow += '<td style="white-space: normal;"><span class="executorSpan">'+h.find("#executor").val()+'</span>'+
						'<input type="hidden" name="executor" value="'+h.find("#executor").val()+'"/></td>';
					}
					if(typeof($("#enquiryDateSpan").html())!="undefined"){
						newRow += '<td style="white-space: normal;"><span class="enquiryDateSpan">'+h.find("#enquiryDate").val()+'</span>'+
						'<input type="hidden" name="enquiryDate" value="'+h.find("#enquiryDate").val()+'"/></td>';
					}
				
					if(typeof($("#deliveryDateSpan").html())!="undefined"){
						newRow += '<td style="white-space: normal;"><span class="deliveryDateSpan">'+h.find("#deliveryDate").val()+'</span>'+
						'<input type="hidden" name="deliveryDate" value="'+h.find("#deliveryDate").val()+'"/></td>';
					}
					
					if(typeof($("#expirationDateSpan").html())!="undefined"){
						newRow += '<td style="white-space: normal;"><span class="expirationDateSpan">'+h.find("#expirationDate").val()+'</span>'+
						'<input type="hidden" name="expirationDate" value="'+h.find("#expirationDate").val()+'"/></td>';
					}
					if(typeof($("#affirmFlagSpan").html())!="undefined"){
						//affirmFlagSpanError
						
						var affirmFalgValue ;
						var obj = $("input[name=affirmFlag]");
					    for(var i=0; i<obj.length; i ++){
					        if(obj[i].checked){
					        	affirmFalgValue = obj[i].value;
					        }
					    }
					    if(affirmFalgValue==1){newRow += '<td style="white-space: normal;"><span class="affirmFlagSpan"><i class="icon-ok" style="color: red;"></i></span>'+
							'<input type="hidden" name="affirmFlag" value="'+affirmFalgValue+'"/></td>';}
					    else{newRow += '<td style="white-space: normal;"><span class="affirmFlagSpan"><i class="icon-remove"></i></span>'+
							'<input type="hidden" name="affirmFlag" value="'+affirmFalgValue+'"/></td>';}
						
					}
					if(typeof($("#remarksSpan").html())!="undefined"){
						newRow += '<td style="white-space: normal;"><span class="remarksSpan">'+h.find("#remarks").val()+'</span>'+
						'<input type="hidden" name="virtualDetailRemarks" value="'+h.find("#remarks").val()+'"/></td>';
					}
					newRow += '<td style="white-space: normal;"><a href="javascript:" onclick="editRow(this)"><i class="icon-edit"></i></a>&nbsp; '+
						'<a href="javascript:" class="deleteRowBy"><i class="icon-remove"></i></a></td></tr>';
					$("#productInfoTbody").append(newRow);
					$("#productName").attr("value","");
					$("#productCode").attr("value","");
					$("#specifications").attr("value","");
					$("#brand").attr("value","");
					$("#packaging").attr("value","");
					$("#unit").attr("value","");
					$("#supplier").attr("value","");
					$("#productCodeNum").attr("value","");
					$("#supplierCodeNum").attr("value","");
					}else{
						$.jBox.tip("请选择产品", "warn");
						return false
					}
				}else {
					$("#productName").attr("value","");
					$("#productCode").attr("value","");
					$("#specifications").attr("value","");
					$("#brand").attr("value","");
					$("#packaging").attr("value","");
					$("#unit").attr("value","");
					$("#supplier").attr("value","");
					$("#productCodeNum").attr("value","");
					$("#supplierCodeNum").attr("value","");
					return true;
				}
			}
		}); 
	}

/**
 * 全局变量
 */
var pageNoOne;//页码
var pageSizeOne;//页码大小
var countOne;//总数

//按产品名称查询产品

/**
 * 导出
 */
$("#btnExport").live("click",function() {
	
	var virtualContractId = $("#virtualContractId").val();//客户合同ID
	top.$.jBox.confirm("确认要导出产品数据吗？", "系统提示", function(v, h, f) {
		if (v == "ok") {
			$("#saveForm").attr("action", ctx + "/pro/virtualDetail/export");
			$("#saveForm").submit();
			/* window.location.href="/jeesite/a/pro/virtualDetail/export?ID="+virtualContractId; */
		}
	}, {
		buttonsFocus : 1
	});
		top.$('.jbox-body .jbox-icon').css('top', '55px');
	});
/**
 * 导入
 */
$("#btnImport").live("click",function() {
	$.jBox($("#importBox").html(), {
		title : "导入数据",
		buttons : {
			"关闭" : true
		},
		bottomText : "导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"
	});
});

//升级为客户合同
function upgradeContract(){
	var submit = function (v, h, f) {
	    if (v == 'ok'){
	var json = "";
	$.each($("#productInfoTbody tr"), function(i,info){
		var virtualDetailId = $("#productInfoTbody tr:eq("+i+") input[name=virtualDetailId]").val();//合同产品信息ID
		var productName = $("#productInfoTbody tr:eq("+i+") input[name=productName]").val();//产品名称
		var productCode = $("#productInfoTbody tr:eq("+i+") input[name=productCode]").val();//产品代码
		var specifications = $("#productInfoTbody tr:eq("+i+") input[name=specifications]").val();//规格
		var brand = $("#productInfoTbody tr:eq("+i+") input[name=brand]").val();//品牌
		var packaging = $("#productInfoTbody tr:eq("+i+") input[name=packaging]").val();//封装
		var unit = $("#productInfoTbody tr:eq("+i+") input[name=unit]").val();//单位
		var supplier = $("#productInfoTbody tr:eq("+i+") input[name=supplier]").val();//供应商
		var noTaxPrice = $("#productInfoTbody tr:eq("+i+") input[name=noTaxPrice]").val();//未税价格
		var taxPrice = $("#productInfoTbody tr:eq("+i+") input[name=taxPrice]").val();//含税价格
		var count = $("#productInfoTbody tr:eq("+i+") input[name=count]").val();//数量
		var brandReplace = $("#productInfoTbody tr:eq("+i+") input[name=brandReplace]").val();//品牌替代说明
		var abnormalProblem = $("#productInfoTbody tr:eq("+i+") input[name=abnormalProblem]").val();//异常问题确认
		var executor = $("#productInfoTbody tr:eq("+i+") input[name=executor]").val();//对应负责人
		var enquiryDate = $("#productInfoTbody tr:eq("+i+") input[name=enquiryDate]").val();//询价日期
		var abnormalProblem = $("#productInfoTbody tr:eq("+i+") input[name=abnormalProblem]").val();//异常问题确认
		var deliveryDate = $("#productInfoTbody tr:eq("+i+") input[name=deliveryDate]").val();//送货日期
		var expirationDate = $("#productInfoTbody tr:eq("+i+") input[name=expirationDate]").val();//保质期
		var affirmFlag = $("#productInfoTbody tr:eq("+i+") input[name=affirmFlag]").val();//是否中标
		var virtualDetailRemarks = $("#productInfoTbody tr:eq("+i+") input[name=virtualDetailRemarks]").val();//备注
		
		var productCodeNum = $("#productInfoTbody tr:eq("+i+") input[name=productCodeNum]").val();//保质期
		var supplierCodeNum = $("#productInfoTbody tr:eq("+i+") input[name=supplierCodeNum]").val();//保质期
		
		if(typeof(virtualDetailId) == "undefined"){
			virtualDetailId = "";
		}
		if(typeof(productName) == "undefined"){
			productName = "";
		}

		if(typeof(productCode) == "undefined"){
			productCode = "";
		}

		if(typeof(specifications) == "undefined"){
			specifications = "";
		}
		if(typeof(brand) == "undefined"){
			brand = "";
		}

		if(typeof(packaging) == "undefined"){
			packaging = "";
		}

		if(typeof(unit) == "undefined"){
			unit = "";
		}

		if(typeof(supplier) == "undefined"){
			supplier = "";
		}
		if(typeof(noTaxPrice) == "undefined"){
			noTaxPrice = "";
		}
		if(typeof(taxPrice) == "undefined"){
			taxPrice = "";
		}
		
		if(typeof(count) == "undefined"){
			count = "";
		}
		if(typeof(brandReplace) == "undefined"){
			brandReplace = "";
		}
		if(typeof(abnormalProblem) == "undefined"){
			abnormalProblem = "";
		}
		if(typeof(executor) == "undefined"){
			executor = "";
		}
		if(typeof(abnormalProblem) == "undefined"){
			abnormalProblem = "";
		}
		if(typeof(deliveryDate) == "undefined"){
			deliveryDate = "";
		}
		if(typeof(expirationDate) == "undefined"){
			expirationDate = "";
		}
		if(typeof(virtualDetailRemarks) == "undefined"){
			virtualDetailRemarks = "";
		}
		if(typeof(enquiryDate) == "undefined"){
			enquiryDate = "";
		}
		if(productCodeNum == "undefined"){
			productCodeNum = "";
		}
		if(supplierCodeNum == "undefined"){
			supplierCodeNum = "";
		}
		if(typeof(affirmFlag) == "undefined"){
			affirmFlag = "";
		}
		if(affirmFlag == "1"){
			if(affirmFlag == "1" && i > 0){
				json = json+','
			}
			json = json+'{"virtualDetailId":"'+virtualDetailId+'","productName":"'+productName+'","productCode":"'+productCode+
			'","specifications":"'+specifications+'","brand":"'+brand+'","packaging":"'+packaging+'","unit":"'+unit+
			'","supplier":"'+supplier+'","count":"'+count+'","noTaxPrice":"'+noTaxPrice+'","taxPrice":"'+taxPrice+
			'","brandReplace":"'+brandReplace+'","abnormalProblem":"'+abnormalProblem+'","executor":"'+executor+
		    '","enquiryDate":"'+enquiryDate+'","deliveryDate":"'+deliveryDate+'","expirationDate":"'+expirationDate+
		    '","affirmFlag":"'+affirmFlag+'","remarks":"'+virtualDetailRemarks+
		    '","productCodeNum":"'+productCodeNum+'","supplierCodeNum":"'+supplierCodeNum+'"}';
		}
	});
	var virtualDetail = '['+json+']';
	location.href = ctx+"/pro/virtualDetail/upgradeContract?RealDetail="+virtualDetail;
	    }
	 else if (v == 'cancel'){
	    	return true;
	    }
};
$.jBox.confirm("升级过程中,只包含中标信息,是否升级 ？", "提示", submit);
}